<template>
   <div class="all">
     <el-table :data="pagination.records" border >
      <el-table-column fixed="left" prop="nickName" label="昵称" width="120"></el-table-column>
      <el-table-column prop="comment_id" label="评论id" width="100"></el-table-column>
      <el-table-column prop="exp_id" label="实验id" width="200"></el-table-column>
      <el-table-column prop="parent_id" label="父id" width="120"></el-table-column>
      <el-table-column prop="userFace" label="头像地址" :show-overflow-tooltip="true" width="155"></el-table-column>
      <el-table-column prop="content" label="评论内容" width="120"></el-table-column>
      <el-table-column prop="create_time" label="评论时间" width="200"></el-table-column>
      <el-table-column prop="create_time" label="评论时间" width="200"></el-table-column>
    </el-table>
    <el-pagination
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page="pagination.current"
      :page-sizes="[6, 10]"
      :page-size="pagination.size"
      layout="total, sizes, prev, pager, next, jumper"
      :total="pagination.total"
      class="page">
    </el-pagination>
   </div>
</template>

<script>
export default {
  name: 'ExpComment',
  data() {
    return {
      pagination: {
        //分页后的考试信息
        current: 1, //当前页
        total: null, //记录条数
        size: 6, //每页条数
      },
      title:'',
      dialogVisible: false, //对话框
      form: {}, //保存点击以后当前试卷的信息
    };
  },
  methods: {
    initRole() {
      if(!window.sessionStorage.getItem('user')){
        this.$message.error('请先进行登录!')
        this.$router.push({path: '/'})
      }
      
      var a = JSON.parse(window.sessionStorage.getItem('user'))

      if(a.roleType == 1|| a.roleType == 2){
        this.$message.error('权限不足!')
        this.$router.push({path: '/'})
      }
    },
    getExpComment(){
      this.$axios(`/exp-comment/findAll/${this.pagination.current}/${this.pagination.size}`,).then(res => {
        this.pagination = res.obj;
      }).catch(error => {});
    },
    //改变当前记录条数
    handleSizeChange(val) {
      this.pagination.size = val;
      this.getExpComment();
    },
    //改变当前页码，重新发送请求
    handleCurrentChange(val) {
      this.pagination.current = val;
      this.getExpComment();
    },
  },
  
  created() {
    this.initRole()
    this.getExpComment()
  },
}
</script>

<style>
</style>